import { defineComponent, ref, h } from 'vue'

export default defineComponent({
  name: 'demo',
  emits: ['itemClick'],
  props: {
    title: {
      type: String,
      default: 'demo',
    },
  },
  render() {
    return h(
      'div',
      {
        onClick: this.hiClick,
      },
      [h('p', {}, '123' + this.hi), h('p', {}, '456')]
    )
  },
  setup(props, ctx) {
    const { slots, emit, expose } = ctx
    const hi = ref('hi123!')
    const hiClick = () => {
      hi.value = 'hiClick!'
      emit('itemClick', 'itemClick')
      console.log(hi.value)
    }
    // 指定导出组件方法或值
    expose({
      // hi,
      hiClick,
      v: '1.0.0',
    })
    return {
      hi,
      hiClick,
    }
  },
})
